package com.zhuss.meeting.room;

import com.zhuss.bean.bo.meeting.apply.CheckApplyBo;
import com.zhuss.bean.bo.meeting.room.DetailRoomBo;
import com.zhuss.bean.bo.meeting.room.SearchRoomBo;
import com.zhuss.common.AbstractBo;
import com.zhuss.common.ReadService;
import com.zhuss.common.SelectVo;
import com.zhuss.core.processor.EnumConfig;
import com.zhuss.exception.WpsException;
import com.zhuss.meeting.processor.RoomRead;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Author: zhushanshuo
 * @Date: 2020/2/12 19:39
 */
@Component("roomReadService")
public class RoomReadService implements ReadService<Object,Object>{

    @Autowired
    @Qualifier("roomRead")
    private RoomRead roomRead;

    @Autowired
    @Qualifier("enumConfig")
    private EnumConfig enumConfig;

    @Override
    public Object detail(Object o) throws WpsException {
        DetailRoomBo bo = (DetailRoomBo) o;
        Long roomId = bo.getRoomId();
        Object vo = roomRead.detail(roomId);
        return vo;
    }

    @Override
    public Object list(Object o) throws WpsException {
        SearchRoomBo bo = (SearchRoomBo) o;
        Object result = roomRead.list(bo);
        return result;
    }

    /**
     * 获取可分配会议室
     * @throws WpsException
     */
    public Object check(CheckApplyBo o) throws WpsException {
        Object result = roomRead.checkList(o);
        return result;
    }

    /**
     * 获取会议室装配
     * @param o
     * @return
     * @throws WpsException
     */
    public Object getRoomDevice(AbstractBo o) throws WpsException {
        List<SelectVo> selectList = enumConfig.listSelectRoomDevice(o.getConcurrentArea());
        return selectList;
    }
}
